Skip to content

feat: event workflow_run support#732

Merged
andykenward merged 11 commits into
mainfrom
pr/pull_request_target
May 4, 2026
Merged

feat: event workflow_run support#732
andykenward merged 11 commits into
mainfrom
pr/pull_request_target

Conversation

@andykenward

@andykenward andykenward commented May 3, 2026

Copy link
Copy Markdown
Owner

Summary

Adds support for the GitHub Actions workflow_run event so this action can deploy and comment reliably for fork-based pull request flows, while preserving existing behavior for push, pull_request, and workflow_dispatch.

#729.

Why

Fork pull requests often cannot access repository secrets in pull_request workflows. A follow-up workflow_run job in the base repository can run with the required permissions and secrets. This change makes that flow first-class in the action.

What changed

  1. Added workflow_run as a supported deploy trigger in runtime event validation.
  2. Updated GitHub context resolution for workflow_run to use workflow_run.head_branch and workflow_run.head_sha so deployment metadata and comments point to the correct source commit.
  3. Refactored PR node ID lookup logic in comment creation:
    • workflow_run: finds the matching pull request from workflow_run.pull_requests by branch and sha, then fetches the PR node ID via GraphQL by PR number.
    • workflow_dispatch: switched from REST pagination to a GraphQL query that resolves the open PR by head branch.
    • pull_request: retained behavior, with clearer error messaging for missing node IDs.
  4. Added new GraphQL operations and regenerated typed GraphQL artifacts:
    • PullRequestNodeId
    • PullRequestNodeIdByBranch
  5. Expanded tests to cover:
    • workflow_run context behavior
    • successful workflow_run comment creation
    • workflow_run error cases (no match, multiple matches)
    • workflow_dispatch GraphQL lookup success/failure
    • unsupported events still no-op for comment creation
  6. Updated documentation with a fork-safe workflow_run example and explanation of expected behavior.
  7. Added a changeset indicating a minor release.
  8. Included TypeScript/tooling updates reflected in lockfiles and tsconfig (Node types explicitly included).

Validation

  1. Full project checks passed via pnpm run all.
  2. New and updated tests cover happy paths and edge cases for workflow_run and workflow_dispatch comment resolution.

Impact

  1. Enables secure PR preview deployments for fork contributions using workflow_run.
  2. Improves consistency of commit/branch metadata used in deployments and PR comments.
  3. Reduces REST pagination dependency in comment PR lookup by using typed GraphQL queries.

@changeset-bot

changeset-bot Bot commented May 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1970046

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@andykenward andykenward force-pushed the pr/pull_request_target branch from 986c52b to a66edf3 Compare May 3, 2026 18:25
@andykenward andykenward changed the title Pr/pull request target Support approved forks #729 May 3, 2026
@andykenward andykenward changed the title Support approved forks #729 Support approved forks workflow May 3, 2026
@andykenward andykenward force-pushed the pr/pull_request_target branch from 6133612 to 80cb89e Compare May 4, 2026 17:56
@andykenward andykenward changed the title Support approved forks workflow feat: event workflow_run support May 4, 2026
@andykenward andykenward changed the title feat: event workflow_run support feat: event workflow_run support May 4, 2026
andykenward and others added 4 commits May 4, 2026 18:05
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@andykenward andykenward marked this pull request as ready for review May 4, 2026 19:19
@andykenward andykenward merged commit 1c10be0 into main May 4, 2026
5 checks passed
@andykenward andykenward deleted the pr/pull_request_target branch May 4, 2026 19:19
@github-actions github-actions Bot mentioned this pull request May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eventName pull_request_target is not supported - any other solution to deploy and preview from PR based on a fork?

1 participant